<div class="page-3 cart commonPage">
	<div class="bg-3"></div>
	<?php echo $this->element('sidebar'); ?>
	<div class="box-right zhigh">
        <?php echo $this->element('banner'); ?>
            <div class="title">
                <ul class="breadcrumbs">
                    <li><a href="<?php echo $this->General->base_url() ?>"><img style="position: relative; top: 2px;" src="<?php echo $this->webroot ?>images/home-yl-2.png" /></a></li>
                    <?php
                        foreach($breadcrumbs as $breadcrumb)
                        {
                            echo '<li><a href="'.$this->General->base_url().$breadcrumb['link'].'">'.$breadcrumb['title'].'</a></li>';
                        }
                    ?>
                </ul>
			</div>
		<?php echo $this->element('header'); ?>
		<div class="box-content">
			<div class="post-content">

                <div class="info-user">
                    <?php echo $this->Session->flash(); ?>
                    <h4>Thông tin tài khoản</h4>
                    <p>
                        <label>Tên đăng nhập:</label>
                        <span>
                            <?php echo $info_user['username'] ?>
                            (<a href="<?php echo $this->General->base_url() . 'users/edit' ?>">Sửa</a>)
                        </span>
                    </p>
                    <p>
                        <label>Mật khẩu:</label>
                        <span><a href="<?php echo $this->General->base_url() . 'users/change_password' ?>">Đổi mật khẩu</a></span>
                    </p>
                    <p>
                        <label>Họ tên:</label>
                        <span><?php echo $info_user['name'] ?></span>
                    </p>
                    <p>
                        <label>Email:</label>
                        <span><?php echo $info_user['email'] ?></span>
                    </p>
                    <p>
                        <label>Ngày sinh:</label>
                        <span><?php echo $info_user['date_birth'] ?></span>
                    </p>
                    <p>
                        <label>Số điện thoại:</label>
                        <span><?php echo $info_user['phone'] ?></span>
                    </p>
                    <p style="display:inline-block; width:100%">
                        <label>Giới tính:</label>
                        <?php
                            if($info_user['gender'] == 1)
                                echo '<span>Nam</span>';
                            if($info_user['gender'] == 0)
                                echo '<span>Nữ</span>';
                        ?>
                    </p>
                    <p>
                        <label>Địa chỉ:</label>
                        <span><?php echo $info_user['address'] ?></span>
                    </p>
                </div>
                <div class="info-cart">
                    <h4>Thông tin đơn hàng</h4>
                    <table>
                        <tr>
                            <th>STT</th>
                            <th>Mã đơn hàng</th>
                            <th>Ngày đặt hàng</th>
                            <th>Số lượng</th>
                            <th>Giá</th>
                            <th>Trạng thái</th>
                            <th>Chi tiết</th>
                        </tr>
                        <?php
                            if(!empty($info_cart))
                            {
                                $i = 1;
                                foreach($info_cart as $cart)
                                {
                        ?>
                        <tr>
                            <td align="center"><?php echo $i++ ?></td>
                            <td><?php echo $cart['cart']['cart_id'] ?></td>
                            <td><?php echo $cart['cart']['date_added'] ?></td>
                            <?php
                                $cart_detail = $cart['cart_detail'];
                                $sum_amount = 0;
                                $number = 0;
                                foreach($cart_detail as $value)
                                {
                                    $number += $value['cart_detail']['number'];
                                    
                                    $gia = $value['cart_detail']['discount'] > 0 ? $value['cart_detail']['discount'] : $value['cart_detail']['price'];
                                    $amount = $gia * $value['cart_detail']['number'];
                                    $sum_amount += $amount;
                                }
                            ?>
                            <td align="center"><?php echo $number ?></td>
                            <td><?php echo number_format($sum_amount,0,',','.') .' '. $settings['currency'] ?></td>
                            <td><?php echo $cart['cart_status']['title'] ?></td>
                            <?php
                                $link = $this->General->base_url() . 'checkout/review/' . base64_encode($cart['cart']['cart_id']);
                            ?>
                            <td align="center"><a target="_blank" href="<?php echo $link ?>">Xem đơn hàng</a></td>
                        </tr>
                        <?php
                            }
                        }
                        else
                        {
                        ?>
                            <tr><td colspan="7">Bạn chưa có đơn hàng nào.</td></tr>
                        <?php
                        }
                        ?>

                    </table>
                </div>
            </div>
		</div>
	</div>
	<?php echo $this->element('footer'); ?>
</div>
